import java.util.Arrays;

public class insertSort {
    public static void insertSort(int[] arrays){
        for (int i = 1; i < arrays.length ; i++) {
            int j = i - 1;
            int temp = arrays[i];
            for (; j >= 0; j--) {
                if(arrays[j] > temp){
                    arrays[j+1] = arrays[j];
                }else{
                    break;
                }
            }
            arrays[j+1] = temp;
        }
    }
    public static void testInsert(int[] arrays){
        arrays = Arrays.copyOf(arrays,arrays.length);
        long start = System.currentTimeMillis();
        //System.out.println(Arrays.toString(arrays));
        insertSort.insertSort(arrays);
        //System.out.println(Arrays.toString(arrays));
        long end = System.currentTimeMillis();
        System.out.println("插入排序所花费的时间为：" + (end - start));
    }

    public static void main(String[] args) {
        int[] array = new int[10_0000];
        Public.func1(array);
        testInsert(array);

        Public.func2(array);
        testInsert(array);

        Public.func3(array);
        testInsert(array);

    }
}